<template>
	<BaseContainer>
		<aplid-base-crud ref="crud" class="w-100" v-bind="baseConfig">
			<template v-slot:menuColumn="{ row }">
				<el-button class="text-blue" v-auth="'view_iccVeinApprove_edit'" v-if="!row.approveStatus == 0" @click="handleOperate(row, 1)"
					>通过</el-button
				>
				<el-button class="text-red" v-auth="'view_iccVeinApprove_edit'" v-if="!row.approveStatus == 0" @click="handleOperate(row, 0)">驳回</el-button>
			</template>
		</aplid-base-crud>
	</BaseContainer>
</template>

<script setup>
import { baseConfig } from './config'
import { ElMessage, ElMessageBox } from 'element-plus'
import apiMod from '@/apiMod/index'

const handleOperate = (row, approveResult) => {
	const onOperate = (query = {}) => {
		apiMod
			.view_iccVeinApprove_edit({
				...query,
			})
			.then(() => {
				ElMessage({
					type: 'success',
					message: `操作成功`,
				})
			})
	}
	if (approveResult == 0) {
		ElMessageBox.prompt('请输入驳回原因', '提示', {
			confirmButtonText: '确定',
			cancelButtonText: '取消',
		})
			.then(({ value }) => {
				onOperate({
					...row,
					approveRemark: value,
					approveResult,
				})
			})
			.catch(() => {})
	} else {
		onOperate({
			...row,
			approveResult,
		})
	}
}
</script>

<style lang="scss" scoped></style>
